home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / snoopdos_source / snoopdos.h < prev    next >
C/C++ Source or Header  |  1996-02-16  |  41KB  |  1,123 lines

  1. /*
  2.  *        SNOOPDOS.H                                                vi:ts=4
  3.  *
  4.  *      Copyright (c) Eddy Carroll, September 1994.
  5.  *
  6.  *        This header file defines all the global variables and structures
  7.  *        used by the various SnoopDos code modules.
  8.  *
  9.  *        Exactly one module should #define MAIN before including this file,
  10.  *        to ensure that the variables are defined (as opposed to declared).
  11.  */
  12.  
  13. #undef GLOBAL
  14. #undef INIT
  15.  
  16. #ifdef MAIN
  17. #  define GLOBAL
  18. #  define INIT(x)    = x
  19. #else
  20. #  define GLOBAL    extern
  21. #  define INIT(x)
  22. #endif
  23.  
  24. #ifndef SNOOPTEXT_H
  25. #define CATCOMP_NUMBERS
  26. #include "snooptext.h"
  27. #endif
  28.  
  29. #define MSG(x)        TextTable[x]
  30.  
  31. #define MAX(x,y)    ((x) > (y) ? (x) : (y))
  32. #define MIN(x,y)    ((x) < (y) ? (x) : (y))
  33.  
  34. #define BTOC(addr)    ((void *)(((ULONG)(addr)) << 2))
  35.  
  36. #define SETTINGS_BASENAME    "SnoopDos.prefs"
  37. #define LOGFILE_NAME        "SnoopDos.log"
  38. #define PORT_NAME            "SNOOPDOS"
  39. // #define PATCHES_NAME        "SnoopDos Patches"        /* Up to beta 11           */
  40. #define PATCHES_NAME        "SnoopDos Patchlist"    /* Beta 12 onwards       */
  41. #define HELP_BASENAME        "SnoopDos"
  42. #define HELP_AREXX_PORT        "SNOOPDOS_HELP"
  43. #define APPICON_NAME        "SnoopDos"
  44. #define BACKGROUND_NAME        "SnoopDos Support Process"
  45.  
  46. #define MINSTACKSIZE        12288    /* Minimum stack size we can run with    */
  47.  
  48. /*
  49.  *        Global constants
  50.  */
  51. #define MAX_STR_LEN            200        /* Max. string length for misc stuff    */
  52. #define MAX_SHORT_LEN        40        /* Max. short string len for misc stuff    */
  53. #define MAX_LOCK_LEN        100        /* Max. length of a lock string            */
  54. #define MIN_BUF_SIZE        4096    /* Min. size of history buffer            */
  55. #define PC_NAMELEN            40        /* Max. length of cached task names        */
  56. #define MAX_SEGTRACKER_LEN    50        /* Max. len of segtracker module name    */
  57. #define MAX_FORM_LEN        50        /* Max number of format %'s in form str    */
  58. #define NUM_PCACHE_ENTRIES    16        /* No. of task IDs to cache                */
  59. #define NUM_PACKET_ENTRIES    5        /* No. of outstanding packets to cache    */
  60. #define NUM_CACHED_TASKS    10        /* No. of task entries to cache            */
  61. #define MAX_DOS_DEVICES        100        /* Maximum no of DOS devs we recognise    */
  62. #define LOGBUFFER_SIZE        8192    /* Size of buffer for file logging        */
  63. #define SAVEBUFFER_SIZE        4096    /* Size of i/o buffer for saving buffer    */
  64. #define MAX_LOAD_NESTING    3        /* Only 3 levels of nested config files    */
  65. #define MAX_FIELD_LEN        99        /* Maximum width of a format field        */
  66.  
  67. /*
  68.  *        Constants associated with specific functions
  69.  */
  70. #define SETBUF_KEEPOLD        0        /* Keep old buffer when allocating new    */
  71. #define SETBUF_FORCENEW        1        /* Force new, even if means losing old    */
  72.  
  73.                                     /*       --- for ShowBuffer() ---       */
  74. #define DISPLAY_QUICK        1        /* Redraw buffer using quickest method    */
  75. #define DISPLAY_ALL            2        /* Force redraw of all lines in buffer    */
  76. #define DISPLAY_NONE        4        /* Only update vars, don't refresh        */
  77.  
  78.                                     /*      --- for CreateEvent() ---        */
  79. #define NO_EXPAND            0        /* Don't expand filenames to full paths    */
  80. #define EXPAND_NAME            1        /* Do expand filenames to full paths    */
  81.  
  82.                                     /*    --- for InstallNewFormat() ---    */
  83. #define NEW_LISTVIEW        0        /* Indicates new listview format        */
  84. #define NEW_STRING            1        /* Indicates new string format            */
  85.  
  86.                                     /*      -- for MainLoop() --            */
  87. #define DEFAULT_WIDTH        832        /* Default window width                    */
  88. #define DEFAULT_HEIGHT        300        /* Default window height                */
  89.  
  90.                                     /*      -- CurrentLogType --            */
  91. #define LT_FILE                0        /* Currently logging to a file            */
  92. #define LT_DEVICE            1        /* Currently logging to a device        */
  93. #define LT_DEBUG            2        /* Currently logging to debug device    */
  94.  
  95.                                     /*      -- MonitorMode --               */
  96. #define MONITOR_NORMAL        0        /* Monitoring normal activity           */
  97. #define MONITOR_PAUSED        1        /* Currently paused                        */
  98. #define MONITOR_DISABLED    2        /* Currently disabled                    */
  99.  
  100.                                     /*         -- ShowGadget() --            */
  101. #define GADGET_DOWN           0        /* Show gadget in selected state        */
  102. #define GADGET_UP             1        /* Show gadget in unselected state        */
  103.  
  104.                                     /*         -- SelectFont() --            */
  105. #define FONTSEL_WINDOW        0        /* Request new window font                */
  106. #define FONTSEL_BUFFER        1        /* Request new buffer font                */
  107.  
  108.                                     /*         -- SelectFile() --            */
  109. #define FILESEL_LOADCONFIG    0        /* Request name of existing config file    */
  110. #define FILESEL_SAVECONFIG    1        /* Request name of new config file        */
  111. #define FILESEL_DEFLOGNAME    2        /* Request name of default log file        */
  112. #define FILESEL_NEWLOGNAME    3        /* Request name of new log file            */
  113. #define FILESEL_SAVEBUFFER    4        /* Request name of save buffer file        */
  114. #define FILESEL_SAVEWINDOW    5        /* Request name of save window file        */
  115.  
  116.                                     /*         -- SaveConfig() --           */
  117. #define SAVE_NOICON         0        /* Don't save icon with settings file     */
  118. #define SAVE_ICON             1        /* Try and save icon with settings file    */
  119.  
  120.                                     /*        -- SetLogGadget() --          */
  121. #define LG_NOREFRESH        0        /* Don't refresh main log mode gadgets    */
  122. #define LG_REFRESH            1        /* Do refresh main win log mode gadgets    */
  123.  
  124.                                     /*      -- RecalcMainWindow() --        */
  125. #define NOREDRAW_GADGETS    0        /* Don't redraw gadgets after recalc    */
  126. #define REDRAW_GADGETS        1        /* Do redraw gadgets after recalc        */
  127.  
  128.                                     /*      -- UpdateDeviceList() --        */
  129. #define SCANDEV_DELAY        0        /* Wait before checking for new devices    */
  130. #define SCANDEV_IMMEDIATE    1        /* Check for new devices immediately    */
  131.  
  132.                                     /*      -- CreateCustomImage() --        */
  133. #define IMAGE_FONT            0        /* Request image for font button        */
  134. #define IMAGE_FILE            1        /* Request image for file button        */
  135.  
  136.                                     /*         -- SaveBuffer() --            */
  137. #define SAVEBUF_WINDOW        0        /* Save only visible portion of buffer    */
  138. #define SAVEBUF_ALL            1        /* Save entire buffer                    */
  139. #define SAVEBUF_CLIPBOARD    ((char *)(-1)) /* Indicates saving to clipboard    */
  140.  
  141. #define SAVEBUF_PROMPT        0        /* Prompt user before overwriting file    */
  142. #define SAVEBUF_OVERWRITE    1        /* Always verwrite existing file        */
  143.  
  144. #define KB_SHORTCUT_SIZE    256        /* Size of array for keyboard shortcuts    */
  145.  
  146. /*
  147.  *        Macro (courtesy of Doug Walker) used to allocate longword-aligned
  148.  *        data on the stack. We can't use __aligned inside our patches
  149.  *        because the caller may not have a longword-aligned stack.
  150.  */
  151. #define D_S(name, type) char c_##name[sizeof(type)+3];\
  152.                         type *name = (type *)((long)(c_##name+3) & ~3)
  153.  
  154. /*
  155.  *        This is the template used to match tasks, when we exclude the
  156.  *        Workbench and Shell tasks from the list. %s refers to the user's
  157.  *        chosen pattern. We really want to use a pattern of (A & B) where
  158.  *        A is the pattern that excludes Workbench/Shell and B is the
  159.  *        user pattern. Since AmigaDOS doesn't support an & operator, we
  160.  *        need to use boolean logic to transform this to ~(~A | ~B) which
  161.  *        produces the string below.
  162.  *
  163.  *        PAT_EASY_EXCLUDE is used when there is no match string -- it's a
  164.  *        slightly simpler (and hopefully faster) version of the exclude
  165.  *        system tasks string.
  166.  */
  167. #define PAT_COMPLEX_EXCLUDE    "~((Workbench|Shell Process|Background CLI)|~(%s))"
  168. #define PAT_EASY_EXCLUDE    "~(Workbench|Shell Process|Background CLI)"
  169.  
  170. /*
  171.  *        Some list stuff
  172.  */
  173. typedef struct List                List;
  174. typedef struct MsgPort            MsgPort;
  175. typedef struct Node                Node;
  176. typedef struct SignalSemaphore    Semaphore;
  177. typedef struct Task                Task;
  178. typedef struct Process            Process;
  179. typedef struct Requester        Requester;
  180.  
  181. #define HeadNode(list)        ((void *)((list)->lh_Head))
  182. #define TailNode(list)        ((void *)((list)->lh_TailPred))
  183. #define NextNode(node)        ((void *)((Node *)(node))->ln_Succ)
  184. #define PrevNode(node)        ((void *)((Node *)(node))->ln_Pred)
  185.  
  186. #define FORLIST(list,p)        for ((p) = (void *)(list)->lh_Head;            \
  187.                                  ((Node *)(p))->ln_Succ;                \
  188.                                  (p) = (void *)((Node *)(p))->ln_Succ)
  189.  
  190.  
  191. /*
  192.  *        Now our gadget IDs
  193.  *
  194.  *        If you're changing the order of the first 20-30 boolean gadgets,
  195.  *        then be sure to make corresponding changes to the tables contained
  196.  *        in PATCHES.C and SETTINGS.C.
  197.  */
  198. typedef enum {
  199.     GID_DUMMY,            /* Make sure gadget ID never equals zero */
  200.  
  201. #define FIRST_BOOL_GADGET    GID_FINDPORT
  202.  
  203. #define FIRST_SYS_GADGET    GID_FINDPORT
  204.  
  205.     GID_FINDPORT,        
  206.     GID_FINDRESIDENT,    
  207.     GID_FINDSEMAPHORE,    
  208.     GID_FINDTASK,        
  209.     GID_LOCKSCREEN,        
  210.     GID_OPENDEVICE,        
  211.     GID_OPENFONT,        
  212.     GID_OPENLIBRARY,    
  213.     GID_OPENRESOURCE,    
  214.     GID_READTOOLTYPES,    
  215.     GID_SENDREXX,    
  216.  
  217. #define LAST_SYS_GADGET        GID_SENDREXX
  218. #define NUM_SYS_GADGETS        (LAST_SYS_GADGET - FIRST_SYS_GADGET + 1)
  219.  
  220. #define FIRST_DOS_GADGET    GID_CHANGEDIR
  221.  
  222.     GID_CHANGEDIR,        
  223.     GID_DELETE,            
  224.     GID_EXECUTE,        
  225.     GID_GETVAR,            
  226.     GID_LOADSEG,        
  227.     GID_LOCKFILE,        
  228.     GID_MAKEDIR,        
  229.     GID_MAKELINK,        
  230.     GID_OPENFILE,        
  231.     GID_RENAME,            
  232.     GID_RUNCOMMAND,        
  233.     GID_SETVAR,            
  234.     GID_SYSTEM,
  235.  
  236. #define LAST_DOS_GADGET        GID_SYSTEM
  237. #define NUM_DOS_GADGETS        (LAST_DOS_GADGET - FIRST_DOS_GADGET + 1)
  238.  
  239.     GID_READTOOLTYPES2,            /* Dummy entry to match GID_READTOOLTYPES    */
  240.     GID_LOADSEG2,                /* Dummy entry to match GID_LOADSEG            */
  241.     GID_GETVAR2,                /* Dummy entry to match GID_GETVAR            */
  242.     GID_SETVAR2,                /* Dummy entry to match GID_SETVAR            */
  243.     GID_ADDDOSENTRY,            /* AddDosEntry() (to catch new devices)        */
  244.  
  245. #define GID_NUMPATCHES    (GID_SETVAR2 + 1)    /* Number of patches we have    */
  246.  
  247.     /*
  248.      *        Make sure all gadgets corresponding to patchable DOS functions
  249.      *        appear first in the above list, since they are used to index
  250.      *        directly into the patch list.
  251.      *
  252.      *        Note that we have four additional "dummy" gadget IDs which don't
  253.      *        corresond to actual gadgets. These are used for monitoring
  254.      *        the following function pairs:
  255.      *
  256.      *            GID_READTOOLTYPES:        FindToolType()/MatchToolValue()
  257.      *            GID_LOADSEG:            LoadSeg/NewLoadSeg()
  258.      *            GID_GETVAR:                GetVar()/FindVar()
  259.      *            GID_SETVAR:                SetVar()/DeleteVar()
  260.      *
  261.      *        Whenever the main gadget ID is changed, the library patch code
  262.      *        uses the secondary gadget ID to ensure that _both_ functions
  263.      *        are enabled/disabled. (In fact, this is done at patch time, in
  264.      *        UpdatePatches(), not at the time the gadget itself is clicked.)
  265.      */
  266.  
  267.     /*
  268.      *        Now the remaining gadgets in the function window
  269.      */
  270.     GID_ONLYFAILS,        
  271.     GID_SHOWCLINUM,        
  272.     GID_SHOWPATHS,        
  273.     GID_USEDEVNAMES,    
  274.     GID_MONPACKETS,
  275.     GID_MONALLPACKETS,        
  276.     GID_MONROMCALLS,
  277.     GID_IGNOREWB,        
  278.  
  279.     /*
  280.      *        Now total the number of gadgets so far. Note that these are used
  281.      *        to index into the FuncSettings->Opts array, so don't change
  282.      *        the order of any of the above arbitrarily.
  283.      *
  284.      *        If you DO need to change the order for some reason, make sure to
  285.      *        edit the DefaultSettings array below as well to reflect the new
  286.      *        order!
  287.      */
  288. #define LAST_BOOL_GADGET    GID_IGNOREWB
  289.  
  290. #define GID_NUMFUNCSETS (LAST_BOOL_GADGET+1)  /* Number of function gadgets */
  291.  
  292.     /*
  293.      *        Now the remaining gadget IDs
  294.      */
  295.     GID_PAUSE,
  296.     GID_DISABLE,
  297.     GID_OPENLOG,
  298.     GID_APPENDLOG,
  299.     GID_STARTLOG,
  300.     GID_SERIALLOG,
  301.     GID_CLOSELOG,
  302.     GID_SETUP,
  303.     GID_HIDE,
  304.     GID_QUIT,
  305.     GID_SAVESET,
  306.     GID_FUNCTION,
  307.     GID_STATUS,
  308.  
  309.     GID_LEFTARROW,
  310.     GID_RIGHTARROW,
  311.     GID_UPARROW,
  312.     GID_DOWNARROW,
  313.     GID_HSCROLLER,        /* Two scrollers must come after the four arrows */
  314.     GID_VSCROLLER,
  315.  
  316. #define GID_STARTSCROLL        GID_LEFTARROW
  317. #define GID_ENDSCROLL        GID_VSCROLLER
  318.  
  319.     GID_MATCHNAME,
  320.     GID_SELSYSTEM,
  321.     GID_SELDOS,
  322.     GID_FUNCUSE,
  323.     GID_FUNCCANCEL,
  324.     GID_FUNCUNDO,
  325.     GID_SETUSE,
  326.     GID_SETCANCEL,
  327.     GID_SETUNDO,
  328.     GID_FORMUSE,
  329.     GID_FORMCANCEL,
  330.     GID_FORMUNDO,
  331.     GID_FORMWIDTH,
  332.  
  333.     GID_HIDEMETHOD,
  334.     GID_OPENON,
  335.     GID_LOGMODE,
  336.     GID_FILEIO,
  337.     GID_BUFFERSIZE,
  338.     GID_BUFFORMAT,
  339.     GID_LOGFORMAT,
  340.     GID_HOTKEY,
  341.     GID_SCREENNAME,
  342.     GID_LOGFILE,
  343.     GID_WINDOWFONT,
  344.     GID_BUFFERFONT,
  345.     GID_FORMATEDIT,
  346.     GID_FORMATCOPY,
  347.     GID_FILEPROMPT,
  348.     GID_WFONTPROMPT,
  349.     GID_BFONTPROMPT,
  350.  
  351.     GID_NUM_GADGETS,
  352.  
  353.     /*
  354.      *        All the gadget IDs should appear above this point, since the
  355.      *        symbols are used to index into the Gadget[] array.
  356.      */
  357.  
  358.     /*
  359.      *        Next come the internal menu IDs
  360.      */
  361.     MID_OPENLOG,
  362.     MID_CLOSELOG,
  363.     MID_PAUSE,
  364.     MID_DISABLE,
  365.     MID_STEP,
  366.     MID_CHANGEPRI,
  367.     MID_HELP,
  368.     MID_ABOUT,
  369.     MID_HIDE,
  370.     MID_QUIT,
  371.  
  372.     MID_SETUP,
  373.     MID_FUNCTION,
  374.     MID_FORMAT,
  375.     MID_SETWIDTH,
  376.     MID_ROWQUAL,
  377.     MID_SPACE_NONE,
  378.     MID_SPACE_1P,
  379.     MID_SPACE_2P,
  380.     MID_REF_SIMPLE,
  381.     MID_REF_SMART,
  382.     MID_ALIGN_LEFT,
  383.     MID_ALIGN_RIGHT,
  384.     MID_STATUS,
  385.     MID_GADGETS,
  386.     MID_AUTO_OPEN,
  387.     MID_DISABLE_HIDDEN,
  388.  
  389.     MID_LOAD,
  390.     MID_SAVE,
  391.     MID_SAVEAS,
  392.     MID_RESET,
  393.     MID_LASTSAVED,
  394.     MID_RESTORE,
  395.     MID_ICONS,
  396.  
  397.     MID_COPYWIN,
  398.     MID_COPYBUF,
  399.     MID_SAVEWIN,
  400.     MID_SAVEBUF,
  401.     MID_CLEARBUF
  402.  
  403. } GadgetID;
  404.  
  405. typedef enum {
  406.     MODE_SETTINGS,                /* Executing command in a settings file        */
  407.     MODE_CMDLINE,                /* Executing command on the CLI cmd line    */
  408.     MODE_TOOLTYPE,                /* Executing command in an icon tooltype    */
  409.     MODE_REXX,                    /* Executing command received from ARexx    */
  410.     MODE_INTERNAL,                /* Executing an internal command            */
  411. } ModeEnum;
  412.  
  413. typedef enum {
  414.     HIDE_INVIS,                    /* Make invisible                            */
  415.     HIDE_ICON,                    /* Create Workbench AppIcon                    */
  416.     HIDE_TOOLS,                    /* Create Workbench Tools menu icon            */
  417.     HIDE_NONE,                    /* No hide method                            */
  418.     HIDE_MAX
  419. } HideType;
  420.  
  421. typedef enum {
  422.     SCREEN_DEFAULT,                /* Open window on default public screen        */
  423.     SCREEN_FRONT,                /* Open window on frontmost public screen    */
  424.     SCREEN_NAMED,                /* Open window on named public screen        */
  425.     SCREEN_MAX
  426. } ScreenType;
  427.  
  428. typedef enum {
  429.     LOGMODE_PROMPT,                /* Prompt user for filename                    */
  430.     LOGMODE_APPEND,                /* Append filename to existing file            */
  431.     LOGMODE_OVERWRITE,             /* Overwrite existing file                    */
  432.     LOGMODE_SERIALPORT,            /* Send output to debugger using RawPutChar    */
  433.     LOGMODE_MAX
  434. } LogType;
  435.  
  436. typedef enum {
  437.     FILE_AUTOMATIC,                /* Determine i/o type automatically            */
  438.     FILE_IMMEDIATE,                /* Use immediate i/o (no buffering)            */
  439.     FILE_BUFFERED,                /* Use buffered i/o                            */
  440.     FILE_MAX
  441. } FileIOType;
  442.  
  443. typedef enum {
  444.     ROWQUAL_ANY,                /* Ignore any qualifier when selecting rows    */
  445.     ROWQUAL_NONE,                /* Only select rows if no qualifier given    */
  446.     ROWQUAL_SHIFT,                /* Only select rows if qualifier is shift    */
  447.     ROWQUAL_ALT,                /* Only select rows if qualifier is alt        */
  448.     ROWQUAL_CTRL,                /* Only select rows if qualifier is ctrl    */
  449.     ROWQUAL_ALL                    /* Only select rows if any qualifier given    */
  450. } RowQualifierType;
  451.  
  452. /*
  453.  *        Now structures used throughout SnoopDos
  454.  */
  455.  
  456. /*
  457.  *        This first structure holds details of the actual events
  458.  *
  459.  *        Note that some of these fields are initially defined as NULL or \0
  460.  *        when the event is created, and then filled in when they first need
  461.  *        to be displayed by the mainline code. These are date[], time[],
  462.  *        segname[], hunk, and offset. This is partly because it's dangerous
  463.  *        to call the Date/Time functions via a SetFunction'd patch, and
  464.  *        partly to save time by only decoding those quantities if they're
  465.  *        actually required.
  466.  *
  467.  *        Typically, enough room will be allocated in one of the buffers to
  468.  *        contain both the event and the strings it points to (procname,
  469.  *        filename, segname). Segname is tricky, since it isn't always
  470.  *        necessarily required. It's handled by allocating sufficient room
  471.  *        if segtracking is enabled, or setting it to point to the string
  472.  *        "<Unavailable>" otherwise. (Note that calladdr is used to
  473.  *        determine the segtracker-related info.)
  474.  *
  475.  *        The sequence number is montonically increasing, from the first event
  476.  *        recorded, and is used to allow easy traversal of the buffer.
  477.  *        A seqnum of zero indicates that this event is currently unused.
  478.  *        We use signed rather than unsigned because we occasionally need
  479.  *        to subtract one from another and check if the difference is +ve
  480.  *        or -ve.
  481.  */
  482. typedef struct Event {
  483.     struct MinNode    mnode;        /* Used for linking events together            */
  484.     LONG            seqnum;        /* Sequence number of this event (from 0)    */
  485.     char            *procname;    /* Name of calling process                    */
  486.     char            *action;    /* Type of action (Open, Lock, Load, etc.)    */
  487.     char            *filename;    /* Name of the file being acted on            */
  488.     char            *options;    /* Options associated with this function    */
  489.     char            *result;    /* Result (usually Okay or Fail)               */
  490.     ULONG            processid;    /* Address of process that called us        */
  491.     ULONG            calladdr;    /* Address we were called from                */
  492.     struct DateStamp datestamp;    /* Date and time when we were called        */
  493.     char            date[10];    /* String of date when we were called        */
  494.     char            time[10];    /* String of time when we were called        */
  495.     char            *segname;    /* Pointer to name of caller (segtracker)    */
  496.     ULONG            offset;        /* Offset we were called from (segtracker)    */
  497.     UWORD            hunk;        /* Hunk we were called from (segtracker)    */
  498.     UBYTE            status;        /* Status of this event (see ES_* enums)    */
  499.     UBYTE            flags;        /* See EFLG_* defines below                   */
  500. } Event;
  501.  
  502. #define EFLG_NONE        0        /* Default: No flags set                    */
  503. #define EFLG_DONEDATE    0x01    /* Set if date has been converted to text    */
  504. #define EFLG_DONESEG    0x02    /* Set if segment info has been looked up    */
  505.  
  506. /*
  507.  *        These next two flags are used when logging events to a disk file
  508.  */
  509. #define EFLG_LOGPARTIAL    0x04    /* Set if partial entry for line was logged    */
  510. #define EFLG_LOGDONE    0x08    /* Set if entire entry for line was logged    */
  511.  
  512. /*
  513.  *        These enums define the state of the current event; they are used by
  514.  *        the mainline code while updating the display to ensure we don't try
  515.  *        and access garbage values.
  516.  *
  517.  *        ES_CREATING indicates that the event should not be accessed.
  518.  *
  519.  *        ES_UPDATING indicates that all fields are valid, but some may not
  520.  *        be complete. Thus, the mainline code should continue to output the
  521.  *        contents of this event to the screen whenever it gets a chance.
  522.  *        This is intended to allow Result string to be set after all the
  523.  *        others have already been set (so that the line can be output both
  524.  *        before and after the actual DOS call is made -- that way, if the
  525.  *        call is causing a crash, we can see which call it was.)
  526.  *
  527.  *        ES_READY indicates that the patch code has finished filling in the
  528.  *        event, and the mainline code can go ahead and consider it complete.
  529.  *
  530.  *        ES_ACCEPTED means that the mainline code has seen the line in the
  531.  *        ES_READY state and no longer has to worry about having to check it.
  532.  *
  533.  *        Note that while the patch code is responsible for setting the first
  534.  *        three states, the mainline code sets the final ES_ACCEPTED state.
  535.  */
  536. typedef enum {
  537.     ES_CREATING,                /* This event is being created                */
  538.     ES_UPDATING,                /* This event is being updated                */
  539.     ES_READY,                    /* This event is ready to be displayed        */
  540.     ES_ACCEPTED                 /* This event was successfully displayed    */
  541. } EventStatus;
  542.  
  543. /*
  544.  *        This next structure is used to link all the buffers together. Each
  545.  *        buffer holds a number of variable-size data structures describing
  546.  *        the contents of the buffer.
  547.  */
  548. typedef struct Buffer {
  549.     struct MinNode    mnode;        /* Used for linking buffers together        */
  550.     ULONG            size;        /* Total size of this buffer in bytes        */
  551.     ULONG            free;        /* No. of free bytes remaining in this blk    */
  552.     BYTE           *nextfree;    /* Pointer to next free location in buffer    */
  553.     struct Event    firstevent[1];/* Contains first event in buffer            */
  554. } Buffer;
  555.  
  556. /*
  557.  *        This next structure is used to define the layout of a display format
  558.  *        that can be output to our window or to a disk file. The basic idea
  559.  *        is to encode a string such as "%20f %5d %4r" into an internal form
  560.  *        that can be efficiently scanned to produce the desired result.
  561.  *
  562.  *        Our chosen form is simple, yet efficient. We simply build an array
  563.  *        of this structure, and scan it until we hit an EF_END type.
  564.  */
  565. typedef struct EventFormat {
  566.     char    type;                /* Type of event (see enum FormatID below)    */
  567.     char    width;                /* Width of event column in bytes            */
  568.     short    titlemsgid;            /* Message ID of column title                */
  569. } EventFormat;
  570.  
  571. typedef enum {
  572.     EF_END,
  573.     EF_ACTION,
  574.     EF_CALLADDR,
  575.     EF_DATE,
  576.     EF_HUNKOFFSET,
  577.     EF_PROCID,
  578.     EF_FILENAME,
  579.     EF_PROCNAME,
  580.     EF_OPTIONS,
  581.     EF_RESULT,
  582.     EF_SEGNAME,
  583.     EF_TIME,
  584.     EF_COUNT
  585. } FormatID;
  586.  
  587. #define MAX_BUFFER_WIDTH    (((MAX_FIELD_LEN + 1) * EF_COUNT) + 1)
  588.  
  589. /*
  590.  *        This structure is used to initialise the format fields -- it maps
  591.  *        format types onto corresponding %x sequences and text descriptions
  592.  */
  593. typedef struct {
  594.     char    type;            /* Type of this format field                    */
  595.     char    idchar;            /* Lowercase ascii char used to identify it        */
  596.     char    defwidth;        /* Default width if none specified                */
  597.     short    titlemsgid;        /* Message ID of title                            */
  598. } FieldInit;
  599.  
  600. /*
  601.  *        This structure holds all the settings that will be used
  602.  *        by SnoopDos. We collect them into a single structure to
  603.  *        make it easy to do things like Load/Save settings,
  604.  *        Restore an earlier set of settings, Cancel out of a
  605.  *        settings requester, etc.
  606.  *
  607.  *        There are actually three types of settings: those set via
  608.  *        the Setup... requester, those set via the Functions...
  609.  *        requester, and everything else.
  610.  */
  611. typedef struct SetupSettings {
  612.     UBYTE    HideMethod;                    /* Icon, Tools menu or invisible    */
  613.     UBYTE    ScreenType;                    /* Workbench, Frontmost, or public    */
  614.     UBYTE    LogMode;                    /* Prompt, Append, Overwrite         */
  615.     UBYTE    FileIOType;                    /* Immediate, Buffered, Automatic    */
  616.     ULONG    BufferSize;                    /* In kilobytes                        */
  617.     char    HotKey[MAX_SHORT_LEN];        /* Standard commodities string        */
  618.     char    ScreenName[MAX_SHORT_LEN];    /* Only used with Public ScreenType    */
  619.     char    LogFile[MAX_STR_LEN];        /* Log name if Logmode not Prompt    */
  620.     char    WindowFont[MAX_SHORT_LEN];    /* Default window font                */
  621.     char    BufferFont[MAX_SHORT_LEN];    /* Default buffer font                */
  622.     UWORD    WinFontSize;                /* Size of window font                */
  623.     UWORD    BufFontSize;                /* Size of buffer font                */
  624.     char    BufferFormat[MAX_STR_LEN];    /* Format string for buffer            */
  625.     char    LogfileFormat[MAX_STR_LEN];    /* Format string for logfile        */
  626. } SetupSettings;
  627.  
  628. typedef struct FuncSettings {
  629.     UBYTE    Opts[GID_NUMFUNCSETS];        /* One byte for each setting        */
  630.     char    Pattern[MAX_STR_LEN];        /* Current pattern to match            */
  631. } FuncSettings;
  632.  
  633. typedef struct Settings {
  634.     SetupSettings    Setup;
  635.     FuncSettings    Func;
  636.     UBYTE            AutoOpenMain;        /* If true, auto-open win on output    */
  637.     UBYTE            DisableWhenHidden;    /* If true, disable when hidden        */
  638.     UBYTE            ShowStatus;            /* If true, display status line        */
  639.     UBYTE            ShowGadgets;        /* If true, display gadgets in win    */
  640.     UBYTE            MakeIcons;            /* If true, create icons for config    */
  641.     UBYTE            TextSpacing;        /* 0, 1 or 2: spacing between lines    */
  642.     UBYTE            SimpleRefresh;        /* True = Simple, False = Smart        */
  643.     UBYTE            RightAlign;            /* Right-align target name field    */
  644.     UBYTE            RowQualifier;        /* Cur qualifier for row selection    */
  645.     UBYTE            pad;                /* Keep things neatly aligned        */
  646.     WORD            MainWinLeft;        /* X pos of main window                */
  647.     WORD            MainWinTop;            /* Y pos of main window                */
  648.     WORD            MainWinWidth;        /* Width of main window                */
  649.     WORD            MainWinHeight;        /* Height of main window            */
  650.     WORD            SetupWinLeft;        /* X pos of setup window            */
  651.     WORD            SetupWinTop;        /* Y pos of setup window            */
  652.     WORD            FuncWinLeft;        /* X pos of function window            */
  653.     WORD            FuncWinTop;            /* Y pos of function window            */
  654.     WORD            FormWinLeft;        /* X pos of format window            */
  655.     WORD            FormWinTop;            /* Y pos of format window            */
  656.     WORD            IconPosLeft;        /* X pos of AppIcon (-1 = default)    */
  657.     WORD            IconPosTop;            /* Y pos of AppIcon (-1 = default)    */
  658.     ULONG            StackLimit;            /* Stack limit on patched functions    */
  659. } Settings;
  660.  
  661. /*
  662.  *        These are used when selecting what settings to activate. OR them
  663.  *        together to create combinations.
  664.  */
  665. #define SET_NONE        0                /* No settings changed                */
  666. #define SET_FUNC        1                /* Activate function settings        */
  667. #define SET_SETUP        2                /* Activate setup settings            */
  668. #define SET_MAIN        4                /* Activate main window settings    */
  669.  
  670. #define SET_ALL            (SET_FUNC | SET_SETUP | SET_MAIN)
  671.  
  672. /*
  673.  *        These are the default settings used via "Reset to Defaults"
  674.  */
  675. GLOBAL Settings DefaultSettings
  676. #ifdef MAIN
  677. = {
  678.     /*
  679.      *        First our setup settings
  680.      */
  681.     {
  682.         HIDE_ICON,            /* Hide method                        */
  683.         SCREEN_DEFAULT,        /* Screen type                        */
  684.         LOGMODE_PROMPT,        /* Log method                        */
  685.         FILE_AUTOMATIC,        /* File I/O type                    */
  686.         32,                    /* Buffer size (KB)                    */
  687.         "ctrl alt d",        /* Commodities hotkey                */
  688.         "Workbench",        /* Public screen name                */
  689.         "ram:SnoopDos.log",    /* Default log filename                */
  690.         "",                    /* Window font filled in at startup    */
  691.         "",                    /* Font size filled in at startup    */
  692.         0,                    /* Buffer font filled in at startup    */
  693.         0,                    /* Font size filled in at startup    */
  694.         "%u %p %a %n %o %r",/* Buffer format string                */
  695.         ""                    /* Log format string same as buffer    */
  696.     },
  697.     /*
  698.      *        Now our function settings. Make sure that these match the
  699.      *        order of the GID_* gadget IDs corresponding to each section
  700.      *        which are defined near the start of this file.
  701.      */
  702.      {
  703.         0,                    /* Dummy value, never used            */     
  704.         0,                    /* FindPort                            */
  705.         0,                    /* FindResident                        */
  706.         0,                    /* FindSemaphore                    */
  707.         0,                    /* FindTask                            */
  708.         1,                    /* LockScreen                        */
  709.         0,                    /* OpenDevice                        */
  710.         0,                    /* OpenFont                            */
  711.         0,                    /* OpenLibrary                        */
  712.         0,                    /* OpenResource                        */
  713.         1,                    /* ReadToolTypes                    */
  714.         0,                    /* SendRexx                         */
  715.         1,                    /* ChangeDir                        */
  716.         1,                    /* Delete                            */
  717.         1,                    /* Execute                            */
  718.         0,                    /* GetVar                            */
  719.         1,                    /* LoadSeg                            */
  720.         0,                    /* Lock                                */
  721.         1,                    /* MakeDir                            */
  722.         1,                    /* MakeLink                            */
  723.         1,                    /* Open                                */
  724.         1,                    /* Rename                            */
  725.         0,                    /* RunCommand                        */
  726.         0,                    /* SetVar                            */
  727.         0,                    /* System                            */
  728.         0,                    /* Dummy: ReadToolTypes2            */
  729.         0,                    /* Dummy: LoadSeg2                    */
  730.         0,                    /* Dummy: GetVar2                     */
  731.         0,                    /* Dummy: SetVar2                     */
  732.         0,                    /* Dummy: AddDosEntry                */
  733.         0,                    /* OnlyShowFails                    */
  734.         1,                    /* Show CLI number                    */
  735.         0,                    /* ShowPaths                        */
  736.         0,                    /* UseDevNames                        */
  737.         0,                    /* MonPackets                        */
  738.         0,                    /* Monitor ALL packets                */
  739.         0,                    /* Monitor ROM calls                */
  740.         1,                    /* IgnoreWB                            */
  741.  
  742.         /*
  743.          *        Note that by putting the pattern string at the end,
  744.          *        we can force a warning from the compiler if we update
  745.          *        the GID_* definitions and forget to update the above
  746.          *        list accordingly.
  747.          */
  748.         ""                    /* Default to no special pattern    */
  749.     },
  750.     /*
  751.      *        Now the remaining settings
  752.      */
  753.     0,                        /* No auto-open on output            */
  754.     0,                        /* No disable when hidden            */
  755.     1,                        /* Show status line                    */
  756.     1,                        /* Show gadgets                        */
  757.     1,                        /* Create icons                        */
  758.     0,                        /* 0 spacing between text lines        */
  759.     0,                        /* No simple refresh window            */
  760.     0,                        /* No right aligned target name     */
  761.     ROWQUAL_ANY,            /* Any row qualifier will do        */
  762.     0,                        /* Padding byte                        */
  763.     -1, -1, -1, -1,            /* Main window size/pos (-1 = dflt)    */
  764.     -1, -1,                 /* Setup win   position (-1 = dflt)    */
  765.     -1, -1,                  /* Func window position (-1 = dflt)    */
  766.     -1, -1,                    /* Format window pos    (-1 = dflt) */
  767.     -1, -1,                    /* Icon pos (-1 = dflt)                */
  768.     1000                    /* Stack limit for monitored funcs    */
  769. }
  770. #endif /* MAIN */
  771. ;
  772.  
  773. /*
  774.  *        Some definitions to make it easier to access current global settings
  775.  */
  776. #define OnlyShowFails        CurSettings.Func.Opts[GID_ONLYFAILS]
  777. #define ShowCLINum            CurSettings.Func.Opts[GID_SHOWCLINUM]
  778. #define ShowPaths            CurSettings.Func.Opts[GID_SHOWPATHS]
  779. #define UseDevNames            CurSettings.Func.Opts[GID_USEDEVNAMES]
  780. #define MonPackets            CurSettings.Func.Opts[GID_MONPACKETS]
  781. #define ShowAllPackets        CurSettings.Func.Opts[GID_MONALLPACKETS]
  782. #define MonROMCalls            CurSettings.Func.Opts[GID_MONROMCALLS]
  783. #define IgnoreWBShell        CurSettings.Func.Opts[GID_IGNOREWB]
  784.  
  785. #define MatchName            CurSettings.Func.Pattern
  786.  
  787. #define DefaultLogMode        CurSettings.Setup.LogMode
  788. #define DefaultLogName        CurSettings.Setup.LogFile
  789. #define BufFormat            CurSettings.Setup.BufferFormat
  790. #define LogFormat            CurSettings.Setup.LogfileFormat
  791. #define WindowFontName        CurSettings.Setup.WindowFont
  792. #define WindowFontSize        CurSettings.Setup.WinFontSize
  793. #define BufferFontName        CurSettings.Setup.BufferFont
  794. #define BufferFontSize        CurSettings.Setup.BufFontSize
  795.  
  796. #define AutoOpen             CurSettings.AutoOpenMain
  797. #define DisableOnHide        CurSettings.DisableWhenHidden
  798. #define StatusLine            CurSettings.ShowStatus
  799. #define GadgetsLine            CurSettings.ShowGadgets
  800. #define BoxInterGap            CurSettings.TextSpacing
  801. #define CreateIcons            CurSettings.MakeIcons
  802. #define RefreshTag            (CurSettings.SimpleRefresh ? WA_SimpleRefresh : \
  803.                                                          WA_SmartRefresh)
  804. #define NoCareRefreshBool    (CurSettings.SimpleRefresh ? FALSE : TRUE)
  805. #define RightAligned        CurSettings.RightAlign
  806. #define RowQual                CurSettings.RowQualifier
  807.  
  808. /*
  809.  *        Now, our global variables
  810.  */
  811.  
  812. GLOBAL struct Library *AslBase;                    /* ASL library base            */
  813. GLOBAL struct Library *DiskfontBase;            /* Diskfont library base    */
  814. GLOBAL struct Library *GadToolsBase;            /* GadTools library base    */
  815. GLOBAL struct Library *LayersBase;                /* Layers library base        */
  816. GLOBAL struct Library *IconBase;                /* Icon library base        */
  817. GLOBAL struct GfxBase *GfxBase;                    /* Graphics library base    */
  818. GLOBAL struct Library *RexxSysBase;                /* REXX library base        */
  819. GLOBAL struct Library *UtilityBase;                /* Utility library base        */
  820. GLOBAL struct Library *CxBase;                    /* Commodities base            */
  821. GLOBAL struct Library *AmigaGuideBase;            /* AmigaGuide base            */
  822. GLOBAL struct Library *WorkbenchBase;            /* Workbench base            */
  823. GLOBAL struct Library *KeymapBase;                /* Keymap base                */
  824.  
  825. GLOBAL struct IntuitionBase *IntuitionBase;        /* Intuition library base    */
  826.  
  827. GLOBAL Settings        CurSettings;                /* Our current settings        */
  828. GLOBAL Settings        RestoreSettings;            /* Settings we started with    */
  829. GLOBAL char            *TextTable[NUM_OF_MSGS];    /* Message table for text    */
  830. GLOBAL char            Language[34];                /* Name of current locale    */
  831.  
  832. GLOBAL char            WindowFontDesc[MAX_SHORT_LEN];    /* Font description        */
  833. GLOBAL char            BufferFontDesc[MAX_SHORT_LEN];    /* Font description        */
  834.  
  835. /*
  836.  *        The name used to hold our configuration file, our ASL-selected
  837.  *        log name, and our ASL save buffer name
  838.  */
  839. GLOBAL char            DefaultConfigName[MAX_LOCK_LEN];
  840. GLOBAL char            ConfigFileName[MAX_LOCK_LEN];
  841. GLOBAL char            BufferFileName[MAX_LOCK_LEN]    INIT(LOGFILE_NAME);
  842. GLOBAL char            ChosenLogName[MAX_LOCK_LEN]     INIT(LOGFILE_NAME);
  843.  
  844. /*
  845.  *        This array holds the actual gadget pointer for (almost) all the
  846.  *        gadgets we create; we need this pointer so that we can change
  847.  *        the state of the gadget when the window is open.
  848.  */
  849. GLOBAL struct Gadget *Gadget[GID_NUM_GADGETS];
  850.  
  851. GLOBAL struct DrawInfo        *ScreenDI;            /* Screen render info        */
  852. GLOBAL struct Screen        *SnoopScreen;        /* Screen window is on        */
  853. GLOBAL struct Image            *SizeImage;            /* Size gadget image        */
  854. GLOBAL int                    TitlebarHeight;        /* Height of win titlebar   */
  855. GLOBAL int                    ScreenWidth;        /* Width of SnoopDos screen    */
  856. GLOBAL int                    ScreenHeight;        /* Height of    "    screen */
  857. GLOBAL int                    ScreenResolution;    /* SYSISIZE_(LOWRES|MEDRES)    */
  858. GLOBAL int                    CurWindowWidth;        /* Current window width        */
  859. GLOBAL int                    CurWindowHeight;    /* Current window height    */
  860.  
  861. /*
  862.  *        When ClearMainRHS is set to 1, the right hand side of the main
  863.  *        window will be fully erased on the next redraw (normally, we only
  864.  *        draw out as far as the rightmost entry it the current format, to
  865.  *        save some time).
  866.  *
  867.  *        When PurgeFuncGadgets is 1, the function gadgets will be freed the
  868.  *        next time the functions window is closed (usually set when the
  869.  *        font has been changed).
  870.  */
  871. GLOBAL int ClearMainRHS;
  872. GLOBAL int PurgeFuncGadgets;
  873.  
  874. GLOBAL char   SystemFontName[60];                /* Name of system font        */
  875. GLOBAL struct FontRequester *WindowFR;            /* Window font requester    */
  876. GLOBAL struct FontRequester *BufferFR;            /* Buffer font requester    */
  877.  
  878. GLOBAL struct Window        *MainWindow;        /* Main SnoopDos window        */
  879. GLOBAL struct Window        *FuncWindow;        /* Functions window            */
  880. GLOBAL struct Window        *FormWindow;        /* Format window            */
  881. GLOBAL struct Window        *SetWindow;            /* Settings window            */
  882.  
  883. GLOBAL struct VisualInfo     *MainVI;            /* Main window visual info    */
  884. GLOBAL struct VisualInfo    *FuncVI;            /* Func window visual info    */
  885. GLOBAL struct VisualInfo    *FormVI;            /* Form window visual info    */
  886. GLOBAL struct VisualInfo    *SetVI;                /* Set  window visual info    */
  887.  
  888. GLOBAL struct MsgPort        *MainWindowPort;    /* Msg port for main window    */
  889. GLOBAL struct MsgPort        *FuncWindowPort;    /* Msg port for func window    */
  890. GLOBAL struct MsgPort        *FormWindowPort;    /* Msg port for form window    */
  891. GLOBAL struct MsgPort        *SetWindowPort;        /* Msg port for set window    */
  892. GLOBAL struct MsgPort        *SnoopPort;            /* ARexx message port        */
  893.  
  894. GLOBAL char         StatusLineText[150];        /* Cur. msg in status line    */    
  895. GLOBAL char            CurrentTitle[200];            /* Cur. main window title   */
  896.  
  897. GLOBAL ULONG        MainWindowMask;                /* Sig mask for main window    */
  898. GLOBAL ULONG        FuncWindowMask;                /* Sig mask for func window    */
  899. GLOBAL ULONG        FormWindowMask;                /* Sig mask for format win    */
  900. GLOBAL ULONG        SetWindowMask;                /* Sig mask for set window    */
  901. GLOBAL ULONG        NewEventMask;                /* Sig mask for new DOS evt */
  902. GLOBAL ULONG        WorkbenchMask;                /* Sig mask for WBench msgs    */
  903. GLOBAL ULONG        CommodityMask;                /* Sig mask for CX msgs        */
  904. GLOBAL ULONG        ScanDosListMask;            /* Sig mask to rescan devs    */
  905. GLOBAL ULONG        AmigaGuideMask;                /* Sig mask for AmigaGuide    */
  906. GLOBAL ULONG        RexxPortMask;                /* Sig mask for Rexx msgs    */
  907.  
  908. GLOBAL int            BorderLeft;            /* Width of left border in window    */
  909. GLOBAL int            BorderRight;        /* Width of right border in window    */
  910. GLOBAL int            BorderTop;            /* Height of top border in window    */
  911. GLOBAL int            BorderBottom;        /* Height of bottom border in win   */
  912. GLOBAL int            SquareAspect;        /* True if aspect ratio is 1:1        */
  913. GLOBAL int            GadgetHeight;        /* According to aspect ratio        */
  914. GLOBAL int            GadgetSpacing;        /* According to aspect ratio        */
  915.  
  916. GLOBAL int            QuitFlag;            /* If true, user said quit            */
  917. GLOBAL int            HideOnStartup;        /* True if HIDE found in config        */
  918. GLOBAL int            CommodityPriority;    /* Pri to install Commodity at        */
  919. GLOBAL int            NoPatchRamLib;        /* If true, skip patching ramlib    */
  920. GLOBAL ULONG        SegTrackerActive;    /* Add ev space for ST info         */
  921. GLOBAL ULONG        RomStart;            /* Start ROM address                */
  922. GLOBAL ULONG        RomEnd;                /* End ROM address                    */
  923.  
  924. /*
  925.  *        These variables all deal with the list of monitored events.
  926.  *        All events are numbered in a monotonically increasing manner.
  927.  *        We keep track of the sequence number associated with each
  928.  *        pointer, so that we can easily tell if a pointer is valid
  929.  *        or not by checking if it falls within the range of the
  930.  *        sequence number associated with the first and last events
  931.  *        on the list. (In practice, we only need to check the first
  932.  *        sequence number.)
  933.  *
  934.  *        LastDrawnTopSeq is similar to TopSeq, but differs in the case
  935.  *        where what's displayed in the window has scrolled off the
  936.  *        top of the buffer since the window was last refreshed. In
  937.  *        this case, we can detect that LastDrawnTopSeq is now < FirstSeq
  938.  *        and refresh the window accordingly (when we get an IDCMP_REFRESH
  939.  *        request), rather than refreshing part of the window one way and
  940.  *        part the other.
  941.  *
  942.  *        The EndComplete* variables give the highest event that is
  943.  *        "complete", i.e. that has been set to type ES_ACCEPTED, and
  944.  *        which no longer needs to be refreshed.
  945.  */
  946. GLOBAL List            EventList;                    /* List of captured events    */
  947. GLOBAL Semaphore    BufSem;                        /* Controls  access to list    */
  948. GLOBAL Semaphore    PauseSem;                    /* Controls pausing            */
  949. GLOBAL LONG            NextSeq;                    /* # of newest event          */
  950. GLOBAL LONG            BaseSeq;                    /* All others are > this    */
  951. GLOBAL LONG            FirstSeq;                    /* # of event at window top    */
  952. GLOBAL LONG            RealFirstSeq;                /* as FSeq but ALWAYS right    */
  953. GLOBAL LONG            TopSeq;                        /* # of event at window top    */
  954. GLOBAL LONG            LastDrawnTopSeq;            /* # of event disp'd at top    */
  955. GLOBAL LONG            BottomSeq;                    /* # of event at window bot    */
  956. GLOBAL LONG            MaxScannedSeq;                /* # of highest ev scanned    */
  957. GLOBAL LONG            EndSeq;                        /* # of highest ev scanned    */
  958. GLOBAL LONG            EndCompleteSeq;                /* # of h. complete ev scnd    */
  959. GLOBAL LONG            BufferWidth;                /* Max width of current buf    */
  960. GLOBAL LONG            LogWidth;                    /* Max width of log output    */
  961.  
  962. GLOBAL Event        *TopEvent;                    /* Event at top of screen    */
  963. GLOBAL Event        *BottomEvent;                /* Event at bot of screen    */
  964. GLOBAL Event        *EndEvent;                  /* Highest event scanned    */
  965. GLOBAL Event        *EndCompleteEvent;            /* Max complete event scand */
  966.  
  967. GLOBAL int            HotKeyActive;                /* True if valid hotkey        */
  968. GLOBAL APTR            *TaskWindowPtr;                /* Points to pr_WindowPtr    */
  969. GLOBAL APTR            SaveWindowPtr;                /* Saved value for DOS reqs    */
  970.  
  971. GLOBAL int            MonitorType;                /* See MONITOR_??? defines    */
  972. GLOBAL int            Paused;                        /* If true, we're paused    */
  973. GLOBAL int            Disabled;                    /* If true, we're disabled    */
  974. GLOBAL int            LastKnownState;                /* State when we did HIDE    */
  975. GLOBAL int            LogActive;                    /* If true, we're logging    */
  976. GLOBAL int            GotLastSaved;                /* 1=Last Saved is valid    */
  977.  
  978. GLOBAL int            DisableNestCount;            /* #times DisableWin called    */
  979. GLOBAL Requester    MainRequester;                /* For disabling main win    */
  980. GLOBAL Requester    SetRequester;                /* For disableing setup win    */
  981. GLOBAL Requester    FuncRequester;                /* For disabling func win    */
  982. GLOBAL Requester    FormRequester;                /* For disabling form win    */
  983.  
  984. GLOBAL int            CurrentLogType;                /* See LT_??? defines above    */
  985. GLOBAL char            CurrentLogName[120];        /* Name of current logfile    */
  986.  
  987. GLOBAL struct DateStamp  PauseDateStamp;        /* Time we paused at        */
  988. GLOBAL struct DateStamp  DisableDateStamp;        /* Time we disabled at        */
  989.  
  990. GLOBAL EventFormat    BufferEFormat[MAX_FORM_LEN];/* Format specifier for buf    */
  991. GLOBAL EventFormat    LogEFormat[MAX_FORM_LEN];    /* Format specifier for log    */
  992.  
  993. /*
  994.  *        Prototypes for LANGUAGE.C
  995.  */
  996. void InitTextTable(void);
  997. void InitLocale(char *catalogname);
  998. void CleanupLocale(void);
  999.  
  1000. /*
  1001.  *        Prototypes for BUFFER.C
  1002.  */
  1003. void    InitBuffers(void);
  1004. int     SetTotalBufferSize(ULONG newsize, int alwaystry);
  1005. void    ClearBuffer(void);
  1006. void    CleanupBuffers(void);
  1007. Event  *GetNewEvent(int stringsize);
  1008. void    CopyEvents(UBYTE *newbuf, ULONG newsize, UBYTE *oldbuf, ULONG oldsize);
  1009. int        ParseFormatString(char *formatstr, EventFormat *evformat,
  1010.                                            int maxfields);
  1011. void    BuildFormatString(EventFormat *evformat, char *formatstr, int maxlen);
  1012. char   *UnderlineTitles(EventFormat *ef, char *outstr, char underchar);
  1013. void    CheckSegTracker(void);
  1014.  
  1015. /*
  1016.  *        Prototypes for PATCHES.C
  1017.  */
  1018. void LoadFuncSettings(FuncSettings *func);
  1019. void HandlePatternMsgs(void);
  1020. void UpdateDeviceList(int method);
  1021. void InitRamLibPatch(void);
  1022.  
  1023. /*
  1024.  *        Prototypes for SNOOPDOS.C
  1025.  */
  1026. void InstallSettings(Settings *set, int which);
  1027. void mysprintf(char *outstr, char *fmtstr, ...);
  1028. char *GetFontDesc(char *fontdesc, char *fontname, int size);
  1029.  
  1030. /*
  1031.  *        Prototypes for MAINWIN.C
  1032.  */
  1033. void CleanupMainWindow(void);
  1034. void InitMenus(void);
  1035. void ClearWindowBuffer(void);
  1036. void ShowBuffer(LONG seqnum, int displaytype);
  1037. void DrawSelectedLine(int row, int highlight);
  1038. void HandleNewEvents(void);
  1039. void UpdateMainVScroll(void);
  1040. void SetMenuOptions(void);
  1041. void InstallNewFormat(int type);
  1042. void ReOpenMainWindow(void);
  1043. void RecordWindowSizes(void);
  1044. void SetMonitorMode(int modetype);
  1045. void ScrollHorizontal(int amount);
  1046. void SetLogGadget(int logmode, int refresh);
  1047. int  SaveBuffer(int savetype, char *savename, int overwrite);
  1048. int  OpenLog(int logmode, char *filename);
  1049. void CloseLog();
  1050. void WriteLog(char *string);
  1051. void ShowStatus(char *msg);
  1052. void UpdateStatus(void);
  1053. int  ShowSnoopDos(void);
  1054. void HideSnoopDos(void);
  1055. BOOL OpenMainWindow(void);
  1056. void CloseMainWindow(void);
  1057. int  CheckForScreen(void);
  1058. void UpdateMainHScroll(void);
  1059. void UpdateMainVScroll(void);
  1060. void SetMainHideState(int hidestate);
  1061. int  IsDiskFile(char *filename);
  1062.  
  1063. /*
  1064.  *        Prototypes for SUBWIN.C
  1065.  */
  1066. void CleanupSubWindow(void);
  1067. void HandleFormatMsgs(void);
  1068. void HandleSettingsMsgs(void);
  1069. void HandleFunctionMsgs(void);
  1070. char *GetFuncName(int gadgetid);
  1071. int  OpenFormatWindow(void);
  1072. void CloseFormatWindow(void);
  1073. void CloseFunctionWindow(void);
  1074. void CloseSettingsWindow(void);
  1075. void ShowFuncOpts(UBYTE newopts[], int firstid, int lastid);
  1076. void ResetFuncToSelected(void);
  1077.  
  1078. /*
  1079.  *        Prototypes for MISCWIN.C
  1080.  */
  1081. void InitFonts(void);
  1082. int  SetupScreen(void);
  1083. void CleanupScreen(void);
  1084. void ShowError(char *errormsg, ...);
  1085. int  GetResponse(char *prompts, char *reqmsg, ...);
  1086. int  SelectFont(struct Window *win, int fonttype);
  1087. int  SelectFile(char *newname, char *defname, struct Window *win, int type);
  1088. void AddKeyShortcut(UBYTE *shortcut, int gadid, int msgid);
  1089. struct TextFont *MyOpenFont(struct TextAttr *textattr);
  1090. int  ShowAGuide(char *cmdstring);
  1091. void HandleAGuideMsgs(void);
  1092. void CleanupAGuide(void);
  1093. struct Image *CreateCustomImage(int imagetype, int height);
  1094. void FreeCustomImage(struct Image *image);
  1095. int  ConvertIMsgToChar(struct IntuiMessage *imsg);
  1096. void ShowGadget(struct Window *win, struct Gadget *gad, int type);
  1097.  
  1098. /*
  1099.  *        Prototypes for HOTKEY.C
  1100.  */
  1101. int InstallHotKey(char *hotkey);
  1102. void HandleHotKeyMsgs(void);
  1103. void CleanupHotKey(void);
  1104. void CleanupIcons(void);
  1105. void WriteIcon(char *filename);
  1106. void RemoveProgramFromWorkbench(void);
  1107. int  AddProgramToWorkbench(int hidetype);
  1108. void HandleWorkbenchMsgs(void);
  1109. struct DiskObject *GetProgramIcon(void);
  1110.  
  1111. /*
  1112.  *        Prototypes for SETTINGS.C
  1113.  */
  1114. int  LoadConfig(char *filename, int mode, Settings *set);
  1115. int  SaveConfig(char *filename, int saveicon);
  1116. int  ExecCommand(char *cmdline, int mode, Settings *set);
  1117. int  InitRexxPort(void);
  1118. void HandleRexxMsgs(void);
  1119. void CleanupRexxPort(void);
  1120. void InitSettings(void);
  1121. int  ParseStartupOpts(int argc, char **argv);
  1122. void ShowCommands(BPTR file);
  1123.